<?php
namespace Admin\Model;
use Think\Model;
use Think\Model\RelationModel;
class AnswerModel extends RelationModel{
    //关联关系
    protected $_link = array(
        'Ask'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'ask_id',
            'mapping_fields'=>'title',	//要取出的字段
            'as_fields'=>'title:askTitle'	//使用别名
        ),
        'User'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'user_id',
            'mapping_fields'=>'username',	//要取出的字段
            'as_fields'=>'name:userName'	//使用别名
        )
    );
}